package com.softvan.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;

import com.softvan.dao.SysUserDao;
import com.softvan.entity.SysUser;

public class SysUserServiceImpl implements UserDetailsService{

    @Autowired
    private SysUserDao sysUserDao;
    
    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        SysUser sysUser = sysUserDao.findByUserName(username);
        if (sysUser == null) {
            throw new UsernameNotFoundException("用户名不存在!");
        }
        
        return sysUser;
    }

}
